package com.hroze.util.web;

import org.apache.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * @author zhwang 获得spring ApplicationContext 对像
 * 
 */
public class SpringContext implements ApplicationContextAware {
	private static ApplicationContext context;
	public static final Logger log = Logger.getLogger(SpringContext.class);

	public void setApplicationContext(ApplicationContext con)
			throws BeansException {
		context = con;
		log.info("spring ApplicationContext对象注入：" + context.getDisplayName());
	}

	/**
	 * 获得Spring bean
	 * 
	 * @param beanId
	 * @return
	 */
	public static Object getBean(String beanId) {
		return context.getBean(beanId);
	}
}
